<template>
	<view>
		<cu-custom bgColor="bg-cyan" isBack>
			<block slot="content">input输入框</block>
		</cu-custom>
		<!-- 顶部区域 -->
		<view class="smart-page-head">
			<view class="smart-page-head-title">
				input输入框
			</view>
		</view>
		<view class="smart-padding-wrap">
			<view class="item">可自动获取焦点</view>
			<view><input class="smart-input" focus="true" placeholder="自动获取"></view>
			<view class="item">右下角显示搜索</view>
			<view><input class="smart-input" confirm-type="search" placeholder="右下角显示搜索" /></view>
			<view>同步获取输入值
				<text style="color: #007aff;">{{inputValue}}</text>
			</view>
			<view><input class="smart-input" @input="onKeyInput" placeholder="同步获取输入值"/></view>
			<view>带小数点输入</view>
			<view><input class="smart-input" type="digit" placeholder="这是一个带小数点的输入"/></view>
			<view>身份证输入</view>
			<view><input class="smart-input" type="digit" placeholder="这是一个身份证的输入框"/></view>
			<view>带清除按钮</view>
			<view class="wrapper">
				<input class="smart-input" :value="clearinputValue" @input="clearInput" placeholder="这是一个带清除按钮的输入框" />
				<text v-if="showClearIcon" @click="clearIcon" class="unIcon-delete">&#xe434;</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				inputValue:"",
				showClearIcon:false,
				clearinputValue:""
			}
		},
		methods:{
			onKeyInput(event){
				console.log(event.detail.value);
				this.inputValue = event.detail.value
			},
			clearInput(event){
				this.clearinputValue = event.detail.value;
				if(event.detail.value.length>0) this.showClearIcon = true;
				else this.showClearIcon = false;
			},
			clearIcon(e){
				this.clearinputValue = "";
				this.showClearIcon = false;
			}
		}
	}
</script>

<style>
	.item{
		margin-bottom: 40upx;
	}
	.uni-icon{
		font-family: uniicons;
		font-size: 24px;
		font-weight: normal;
		font-style: normal;
		width: 24upx;
		height: 24upx;
		color: aqua;
		margin-top: 5upx;
	}
	.wrapper{
		display: flex;
		flex-direction: row;
		flex-wrap: nowrap;
		background-color: bisque;
	}
</style>